package com.gxa.logistics.service.impl;

import com.github.pagehelper.PageHelper;
import com.gxa.logistics.common.base.PageWrapperDTO;
import com.gxa.logistics.common.base.RespResult;
import com.gxa.logistics.common.util.PageResultUtil;
import com.gxa.logistics.domain.dto.*;
import com.gxa.logistics.domain.vo.ItemsVO;
import com.gxa.logistics.domain.vo.NewVO;
import com.gxa.logistics.mapper.NewMapper;
import com.gxa.logistics.service.NewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewServiceImpl implements NewService {
    @Autowired
    private NewMapper newMapper;

    @Override
    public RespResult<PageWrapperDTO<NewVO>> list(NewoReqListDTO newoReqListDTO) {
        // 使用分页插件
        PageHelper.startPage(newoReqListDTO.getPageNo(), newoReqListDTO.getPageSize());
        // 包装的分页返回对象
        PageWrapperDTO<NewVO> pageCommon = new PageWrapperDTO<>();
        List<NewVO> newList = newMapper.findNewByDisStatus(newoReqListDTO);
        // 设置分页返回对象
        PageResultUtil.setPageResult(newList,pageCommon);
        return RespResult.success(pageCommon);
    }

    @Override
    public RespResult<PageWrapperDTO<NewVO>> list(NewtReqListDTO newtReqListDTO) {
        // 使用分页插件
        PageHelper.startPage(newtReqListDTO.getPageNo(), newtReqListDTO.getPageSize());
        // 包装的分页返回对象
        PageWrapperDTO<NewVO> pageCommon = new PageWrapperDTO<>();
        List<NewVO> newList = newMapper.findNewByDisStatus1(newtReqListDTO);
        // 设置分页返回对象
        PageResultUtil.setPageResult(newList,pageCommon);
        return RespResult.success(pageCommon);
    }

    @Override
    public void updateNew1(Integer item_num) {
        newMapper.updateNew1(item_num);
    }

    @Override
    public void updateNew2(Integer item_num) {
        newMapper.updateNew2(item_num);
    }

    @Override
    public RespResult<PageWrapperDTO<NewVO>> list(NewReqListDTO newReqListDTO) {
        // 使用分页插件
        PageHelper.startPage(newReqListDTO.getPageNo(), newReqListDTO.getPageSize());
        // 包装的分页返回对象
        PageWrapperDTO<NewVO> pageCommon = new PageWrapperDTO<>();
        List<NewVO> newList = newMapper.findNewByWhere(newReqListDTO);
        // 设置分页返回对象
        PageResultUtil.setPageResult(newList,pageCommon);
        return RespResult.success(pageCommon);
    }

    @Override
    public void insertNew(NewSaveDTO newSaveDTO) {
        newMapper.insertNew(newSaveDTO);
    }

    @Override
    public void updateNew(NewUpdateDTO newUpdateDTO) {
        newMapper.updateNew(newUpdateDTO);
    }

    @Override
    public void deleteNewByitemName(String item_name) {
        newMapper.deleteNewByitemName(item_name);
    }
}
